package ifi.ro.apvs.utils;

import java.awt.Color;
import java.util.ArrayList;

import ifi.ro.apvs.gui.*;

public class PArrayList extends java.util.ArrayList<GPoint> {

	/**
	 * 
	 */
	private ArrayList<Color> colors;
	private ArrayList<Boolean> _isDraw;
	private static final long serialVersionUID = 1L;

	public PArrayList() {
		this.colors = new ArrayList<Color>();
		this._isDraw = new ArrayList<Boolean>();
	}

	public boolean add(GPoint e, Color... c) {
		if (super.add(e)) {
			this._isDraw.add(false);
			if (c.length == 1)
				this.colors.add(c[0]);
			else
				this.colors.add(Color.DARK_GRAY);
			return true;
		}
		return false;
	}

	@Override
	public GPoint remove(int index) {
		GPoint p = super.remove(index);
		if (p != null) {
			if (this.colors.size() > index)
				this.colors.remove(index);
		}
		return p;
	}

	public Color getColor(int index) {
		return this.colors.get(index);
	}

	public void setColor(int index, Color c) {
		if (this.colors.size() > index)
			this.colors.set(index, c);
	}

	public void setDraw(int index, boolean v) {
		if (this._isDraw.size() > 0)
			this._isDraw.set(index, v);
	}

	public boolean isDraw(int index) {
		return this._isDraw.get(index);
	}
}
